Skip to content

Preserve Pi and Claude settings metadata and symlinks on theme activation - #13983

Open
itsandrewtjames wants to merge 2 commits into
omacom:quattrofrom
itsandrewtjames:fix/agent-theme-settings-preservation
Open

itsandrewtjames wants to merge 2 commits into
omacom:quattrofrom
itsandrewtjames:fix/agent-theme-settings-preservation

Conversation

@itsandrewtjames

@itsandrewtjames itsandrewtjames commented Oct 1, 2026 •

Copy link
Copy Markdown

Activating an Omarchy theme for Pi or Claude replaces an existing settings.json with a 0600 temporary file. A settings file managed through a dotfiles symlink becomes a regular file, leaving its target unchanged.

Resolve the existing settings path, stage the replacement beside its referent, preserve its mode, ownership, ACLs and extended attributes, then publish with an atomic rename. The settings update runs in a subshell with an exit trap, so failed parsing, attribute copying or publication removes the stage file and leaves the original settings intact. If the caller cannot preserve the original access metadata, activation fails before replacing the referent.

Addresses the Pi/Claude settings cases called out in #9326. The open shell-config/migration fix (#12250) does not include these helpers; this PR leaves the wider issue open.

Validation:

  • The original regression fixture fails on the base commit: a 0640 Pi settings file becomes 0600.
  • Reproduced both review findings on the initial PR: a shared file's group changed from its supplemental group to the caller's primary group, its named ACL disappeared, and failed JSON parsing left a temporary settings file.
  • bash test/shell.d/agent-theme-settings-test.sh passes for both helpers: modes 0600/0640/0644/0664, unrelated settings, relative symlinks with spaces in the target path, POSIX ACLs, user extended attributes, and supplemental-group ownership.
  • Malformed JSON and injected attribute-copy/rename failures retain the original settings and symlink, propagate the failure status, and leave no settings temporary files.
  • Bash syntax, command metadata, and git diff --check pass.
  • ./test/cli passes the existing Pi/Claude theme checks, then reaches the pre-existing VS Code real-file/symlink assertion failure tracked in test/cli vscode assert expects a symlink that 977e0fcd replaced with a real file #13131. The same failure was verified on an untouched base checkout earlier in this session.

All settings tests use a temporary HOME and synthetic theme/settings files. ACL/xattr tests require getfacl, setfacl, and Python; the supplemental-group test skips only when the test user has no second group.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Updates shell scripts that configure theme settings files.

The PR appears safe to merge; no outstanding findings remain.

Summary

The PR updates Pi and Claude theme activation to write through settings symlinks while retaining file modes and access metadata.

  • Stages the updated JSON beside the symlink referent and publishes it with an atomic rename.
  • Adds regression coverage for modes, symlinks, ACLs, extended attributes, and failed updates.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Pi or Claude activation] --> B[Resolve settings referent]
  B --> C[Stage updated JSON beside referent]
  C --> D[Copy access metadata]
  D --> E[Rename over referent]
  C -->|Failure| F[Remove temporary file]
  D -->|Failure| F
  E -->|Failure| F
Loading

Reviews (2) · Last reviewed commit: "Preserve settings access metadata and cl..."

Comment thread bin/omarchy-theme-set-claude Resolved
Comment thread bin/omarchy-theme-set-claude Resolved
@itsandrewtjames itsandrewtjames changed the title Preserve Pi and Claude settings modes and symlinks on theme activation Preserve Pi and Claude settings metadata and symlinks on theme activation Oct 1, 2026
@omarchybot omarchybot added the bug Something isn't working label Oct 1, 2026
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 7, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at a72ed41 and verified on a disposable worker built from the Omarchy ISO. Nothing needs changing.

Reproduction. A settings.json symlinked into a dotfiles directory, target mode 0644, then omarchy-theme-set-pi --activate and omarchy-theme-set-claude --activate. On quattro, both replace the symlink with a regular 0600 file and leave the dotfiles target unchanged. On this head, the symlink stays, the target gets the new theme, mode stays 0644, other keys are kept and no temporary file is left behind. Pointing the symlink at a target on a vfat filesystem, which has no xattr support, also activates cleanly.

Tests on the worker. test/shell.d/agent-theme-settings-test.sh passes 12 of 12, including the supplemental-group case, and fails on its first assertion against quattro's scripts. user-theme-test.sh passes. ./test/cli passes 91 assertions on both head and base and fails only the VS Code theme-reference assertion, which fails on quattro too (#13131).

Second opinion. Codex at medium effort reviewed the diff and found the subshell, EXIT trap and failure propagation sound, and the test not vacuous. Independence is not guaranteed. It raised two minor points, which I did not act on:

  • A dotfiles target whose filename is 249 bytes or longer would make mktemp fail. No realistic settings file is named that.
  • The test checks for leftover temp files only beside the target, not beside the symlink. A regression that staged next to the symlink would already fail the symlink assertion.

Related. #12250 adds bin/omarchy-config-replace, which does the same resolve, stage, copy-metadata and rename sequence for migrations. If both land, these two scripts could call that helper. This PR addresses the Pi and Claude part of #9326 and leaves the issue open, as the description says.

This is now waiting on the maintainer.

Arash-Afshar added a commit to Arash-Afshar/omarchy that referenced this pull request Nov 6, 2026
…r's pick

omarchy-theme-set-pi wrote the theme and the theme setting into ~/.pi/agent
even when PI_CODING_AGENT_DIR moves Pi's agent tree, so Pi never saw either.
Its Claude and Hermes siblings already follow their agent's variable.

- The agent directory is ${PI_CODING_AGENT_DIR:-~/.pi/agent}, with a leading
  ~ expanded the way Pi expands it (pi 1.5.0 getAgentDir()).
- --activate, which install/user/theme.sh runs on every re-provision, only
  fills in an unset theme. A theme the user picked in Pi is kept.
- The settings write goes through a symlinked settings.json (dotfiles) to its
  target, keeps the file's mode, and leaves the file untouched with no temp
  litter when it is not valid JSON, reporting the failure.

test/shell.d/theme-set-pi-test.sh covers each case; it fails on the first
assertion against the previous script.

Fixes omacom#13691 (theme half). Supersedes omacom#13693, omacom#13718, omacom#13713 (Pi half) and
the Pi half of omacom#13983.
@omarchybot omarchybot removed the ready Good to merge label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants